package com.whmskj.xjlhsc.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.whmskj.xjlhsc.entity.SpecialUseRecord;
import com.whmskj.xjlhsc.service.SpecialUseRecordService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;

/**
 * 维保专件使用记录
 *
 * @author lk
 * @since 2025-06-23 17:03:56
 */
@RestController
@RequestMapping("/api/specialUseRecord")
public class SpecialUseRecordController {

    @Autowired
    private SpecialUseRecordService specialUseRecordService;

    /**
     * 分页查询
     *
     * @param params
     * @return
     */
    @PostMapping("/findPage")
    public ResponseEntity<Page<SpecialUseRecord>> findPage(@RequestBody SpecialUseRecord params) {
        Page<SpecialUseRecord> result = specialUseRecordService.findPage(params);
        return ResponseEntity.ok(result);
    }
    /**
     * 列表查询
     *
     * @param params
     * @return
     */
    @PostMapping("/findList")
    public ResponseEntity<List<SpecialUseRecord>> findList(@RequestBody SpecialUseRecord params) {
        List<SpecialUseRecord> result = specialUseRecordService.findList(params);
        return ResponseEntity.ok(result);
    }

    /**
     * 查询
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public ResponseEntity<SpecialUseRecord> findById(@PathVariable("id") Long id) {
        SpecialUseRecord specialUseRecord = specialUseRecordService.findById(id);
        return ResponseEntity.ok(specialUseRecord);
    }

    /**
     * 新增
     *
     * @param specialUseRecord
     * @return
     */
    @PostMapping
    public ResponseEntity<Boolean> insert( @RequestBody SpecialUseRecord specialUseRecord) {
        boolean result = specialUseRecordService.insert(specialUseRecord);
        return ResponseEntity.ok(result);
    }

    /**
     * 修改
     *
     * @param specialUseRecord
     * @return
     */
    @PutMapping
    public ResponseEntity<Boolean> update( @RequestBody SpecialUseRecord specialUseRecord) {
        boolean result = specialUseRecordService.update(specialUseRecord);
        return ResponseEntity.ok(result);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public ResponseEntity<Integer> delete(@PathVariable("id") Long id) {
        int result = specialUseRecordService.delete(id);
        return ResponseEntity.ok(result);
    }

}